<template>
  <div>
    <section class="section_wrap" v-if="isContract != 0">
      <p>客户姓名：{{ showForm.basicBorrowerName }}</p>
      <el-button
        type="primary"
        style="width: 150px; margin-top: 20px"
        @click="mortgageEvent"
        v-if="isContract == 1 || isContract == 3 || isContract == 4"
        >二抵抵押表下载</el-button
      >
      <el-button
        type="primary"
        style="width: 150px; margin-top: 20px"
        @click="mortgageButton"
        v-if="isContract == 2"
        >二抵抵押表下载</el-button
      >
      <el-button
        type="primary"
        style="width: 150px; margin-top: 20px"
        @click="estate"
        v-if="
          isContract == 1 ||
          isContract == 2 ||
          isContract == 3 ||
          isContract == 4
        "
        >不动产抵押表下载</el-button
      >
      <el-button
        type="primary"
        style="width: 150px; margin-top: 20px"
        v-if=" isContract == 3 || isContract == 4"
        @click="agentFun"
        >保理合同下载</el-button
      >
      <el-button
        type="primary"
        style="width: 150px; margin-top: 20px"
        v-if="isContract == 2"
        @click="blfwFun"
      >保理/服务合同下载</el-button
      >
      <el-button
        type="primary"
        style="width: 150px; margin-top: 20px"
        @click="signatureFun"

        v-if=" isContract == 1  || isContract == 3 || isContract == 4"
        >服务合同下载</el-button
      >
      <el-button
        type="primary"
        style="width: 150px; margin-top: 20px"
        @click="cheackFun"
        >担保合同模板下载</el-button
      >
      <el-button
        type="primary"
        style="width: 150px; margin-top: 20px"
        @click="settlementSign"
        v-if="isShowKHJQJY"
      >客户结清解押表</el-button
      >
      <el-button
        type="primary"
        style="width: 150px; margin-top: 20px"
        @click="businessTable"
        >其它附件下载</el-button
      > <el-button
        type="primary"
        style="width: 150px; margin-top: 20px"
        @click="doorToDoorVisit"
        >上门外访表</el-button
      >
      <!-- 不动产抵押表下载 -->
      <el-dialog
        title="信息核对"
        :visible.sync="dialogVisibleEstate"
        :before-close="handleCloseEstate"
        :append-to-body="true"
        width="1000px"
      >
        <Estate :isContract="isContract" :showForm="showForm" ref="agentDia"></Estate>
      </el-dialog>
      <!-- 保理合同下载 -->
      <el-dialog
        title="信息核对"
        :visible.sync="dialogVisibleAgent"
        :before-close="handleCloseAgent"
        :append-to-body="true"
        width="55%"
      >
        <AgentDia
          :dialogVisible="dialogVisibleAgent"
          :showForm="showForm"
          :isContract="isContract"
          ref="agentDia"
          :borrowerName="borrowerName"
          :orderData="orderData"
        ></AgentDia>
      </el-dialog>
      <!-- 保理服务合同下载 -->
      <el-dialog
        title="信息核对"
        :visible.sync="dialogVisibleBlfw"
        :before-close="handleCloseAgent"
        :append-to-body="true"
        width="55%"
      >
        <Blfw
          :dialogVisible="dialogVisibleBlfw"
          :showForm="showForm"
          :isContract="isContract"
          ref="agentDia"
          :borrowerName="borrowerName"
          :orderData="orderData"
        ></Blfw>
      </el-dialog>
      <!-- 保理签字页下载! -->
      <el-dialog
        title="信息核对"
        :visible.sync="dialogVisibleSignature"
        :before-close="handleCloseSignature"
        :append-to-body="true"
        width="1000px"
      >
        <SignatureDia
          :dialogVisible="dialogVisibleSignature"
          :orderData="orderData"
          :borrowerName="borrowerName"
          :showForm="showForm"
          :isContract="isContract"
          ref="SignatureDia"
        ></SignatureDia>
      </el-dialog>
      <!-- 担保合同模板下载! -->
      <el-dialog
        title="信息核对"
        :visible.sync="dialogVisible"
        :before-close="handleCloseCheck"
        :append-to-body="true"
        width="1000px"
      >
        <CheckDia
          :bdcFDBZ="bdcFDBZ"
          :bdcFDBH="bdcFDBH"
          :bdcDBZ="bdcDBZ"
          :bdcDBH="bdcDBH"
          :bdcZ="bdcZ"
          :bdcH="bdcH"
          :orderData="orderData"
          :borrowerName="borrowerName"
          :showForm="showForm"
          :isContract="isContract"
          ref="CheckDia"
        ></CheckDia>
      </el-dialog>
      <el-dialog
        title="信息核对"
        :visible.sync="dialogVisibles"
        :before-close="handleCloseCheck"
        :append-to-body="true"
        width="1000px"
      >
        <SignatureBL
          :dialogVisible="dialogVisibles"
          :orderData="orderData"
          :borrowerName="borrowerName"
          :showForm="showForm"
          :isContract="isContract"
          ref="CheckDia"
        ></SignatureBL>
      </el-dialog>
      <el-dialog
        title="二抵抵押表信息核对"
        :visible.sync="dialogVisiblesMortgageRYD"
        :before-close="handleCloseCheck"
        :append-to-body="true"
        width="1000px"
      >
        <Mortgage
          v-if="isContract == 1 || isContract == 3 || isContract == 4"
          :isContract="isContract"
          :orderData="orderData"
        >
        </Mortgage>
        <MortgageRYD
          :orderData="orderData"
          v-if="isContract == 2"
          :borrowerName="borrowerName"
          :showForm="showForm"
          :isContract="isContract"
          ref="CheckDia"
        ></MortgageRYD>
      </el-dialog>
<!--      客户结清解压表-->
      <el-dialog
        title="客户结清解押表："
        :visible.sync="dialogVisibleSettlementSign"
        :before-close="handleCloseAgent"
        :append-to-body="true"
        width="55%"
      >
        <SettlementSign
          :dialogVisible="dialogVisibleSettlementSign"
          :showForm="showForm"
          :isContract="isContract"
          ref="agentDia"
          :borrowerName="borrowerName"
          :orderData="orderData"
        ></SettlementSign>
      </el-dialog>
      <!-- 业务推荐表下载! -->
      <el-dialog
        title="其它附件下载"
        :visible.sync="businessDialogVisible"
        width="1000px"
        :before-close="handleClose"
        :append-to-body="true"
      >
        <recommended
          :dialogVisible="businessDialogVisible"
          :orderData="orderData"
          :isContract="isContract"
          :showForm="showForm"
        ></recommended>
      </el-dialog>

    </section>
  </div>
</template>
<script>
import { downLoadOnsite } from "../../assets/js/api";
import CheckDia from "../../components/InformationCheck/Check";
import AgentDia from "../../components/InformationCheck/Agent";
import Blfw from "../../components/InformationCheck/Blfw";
import SignatureBL from "../../components/InformationCheck/SignatureBL";
import MortgageRYD from "../../components/InformationCheck/MortgageTableRYD";
import Mortgage from "../../components/InformationCheck/MortgageTable";
import recommended from "../../components/InformationCheck/businessTable";
import Estate from "../../components/InformationCheck/Estate";
import SettlementSign from "../../components/InformationCheck/settlementSign";

// import SignatureDia from "../../components/InformationCheck/Signature";
import SignatureDia from "../../components/InformationCheck/SignatureBL";
import {checkPermiss} from "../../assets/js/utlis";
/*
*合同模板组件, 默认
* 0没有,
* 1乐业宝,
* 2融银贷,
* 3乐业分，
* 4担保安居分
* */
export default {
  name: "CheckDownLoad",
  components: {
    CheckDia,
    AgentDia,
    SignatureDia,
    SignatureBL,
    Estate,
    MortgageRYD,
    Mortgage,
    recommended,
    SettlementSign,
    Blfw,
  },
  props: {
    showForm: {
      type: Object,
    },
    isContract: {
      type: Number,
    },
    borrowerName: {
      type: String,
    },
    orderData: {
      type: String,
    },
    bdcZ: {
      type: String,
    },
    bdcFDBH: {
      type: String,
    },
    bdcH: {
      type: String,
    },
    bdcDBZ: {
      type: String,
    },
    bdcDBH: {
      type: String,
    },
    bdcFDBZ: {
      type: String,
    },
  },
  data() {
    return {
      dialogVisiblesMortgageRYD: false,
      dialogVisible: false,
      dialogVisibleAgent: false,
      dialogVisibleSignature: false,
      dialogVisibles: false,
      dialogVisibleEstate: false,
      businessDialogVisible: false,

      //结清解押表
      dialogVisibleSettlementSign:false,
      dialogVisibleBlfw: false,

    };
  },
  created() {
    // console.log(this.orderData)
    this.golbalPermissions = localStorage.getItem("permissions").split(",");
  },

  computed:{
    //客户解压表按钮
    isShowKHJQJY:function(){
      if(this.isContract==1){
        //1乐业保
        return checkPermiss('business:contract:downLoadUnpack:lyb',this.golbalPermissions)
      }else if(this.isContract==2){
        //2融银贷
        return checkPermiss('business:contract:downLoadUnpack:ryd',this.golbalPermissions)

      }else if(this.isContract==3){
        //3乐业分
        return checkPermiss('business:contract:downLoadUnpack:lyf',this.golbalPermissions)

      }else if(this.isContract==4){
        //4担保安居分
        return checkPermiss('business:contract:downLoadUnpack:dbajf',this.golbalPermissions)

      }else {
        return false;
      }


    }
  },

  methods: {
    //上门外访表
    doorToDoorVisit(){
      downLoadOnsite(this.orderData).then(res=>{
        window.location = res;
      })
    },
    //结清解压表下载
    settlementSign(){
      this.dialogVisibleSettlementSign=true;
    },

    //乐业保,乐业分,担保安居分二抵抵押表下载!
    mortgageEvent() {
      this.dialogVisiblesMortgageRYD = true;
    },
    // 融银贷二抵抵押表下载!
    mortgageButton() {
      this.dialogVisiblesMortgageRYD = true;
    },
    // 不动产模块下载!
    estate() {
      if (
        this.isContract == 1 ||
        this.isContract == 2 ||
        this.isContract == 3 ||
        this.isContract == 4
      ) {
        this.dialogVisibleEstate = true;
      }
    },

    // 担保合同模板下载
    cheackFun() {
      this.dialogVisible = true;
    },
    // 代理合同下载
    agentFun() {
      this.dialogVisibleAgent = true;
    },

    // 保里服务合同下载
    blfwFun() {
      this.dialogVisibleBlfw = true;
    },
    // 服务合同下载
    signatureFun() {
      if (this.isContract == 2 || this.isContract == 4) {
        this.dialogVisibleSignature = true;
      }
      if (this.isContract == 3 || this.isContract == 1) {
        this.dialogVisibles = true;
      }
    },
    // 业务推荐表按钮!
    businessTable() {
      this.businessDialogVisible = true;
    },
    handleCloseAgent(done) {
      this.$confirm("确认关闭？")
        .then(() => {
          done();
          this.$refs.agentDia.formResetFields(true);
        })
        .catch(() => {});
    },
    handleCloseSignature(done) {
      this.$confirm("确认关闭？")
        .then(() => {
          done();

          this.$refs.SignatureDia.formResetFields(true);
        })
        .catch(() => {});
    },
    handleCloseCheck(done) {
      this.$confirm("确认关闭？")
        .then(() => {
          done();

          this.$refs.CheckDia.formResetFields(true);
        })
        .catch(() => {});
    },
    handleCloseEstate(done) {
      this.$confirm("确认关闭？")
        .then(() => {
          done();

          this.$refs.Estate.formResetFields(true);
        })
        .catch(() => {});
    },
    // 监听事件!
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then(() => {
          done();
          this.$refs.form.formResetFields(); //重置表单
        })
        .catch(() => {});
    },
  },
};
</script>
<style scoped type="less">
.section_wrap {
  text-align: center;
}
</style>
